<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>就诊患者</title>
    <!-- Path to Framework7 Library CSS-->
    <link rel="stylesheet" href="../css/framework7.ios.min.css">
    <link rel="stylesheet" href="../css/framework7.ios.colors.min.css">
    <!-- Path to your custom app styles-->
    <link rel="stylesheet" href="../css/my-app.css">
    <link rel="stylesheet" href="../css/ekang.css"/>
    <style type="text/css">
        .user-name {
            position: absolute;
            font-size: 16px;
            color: black;
            margin-top: 11px;
            margin-left: 43px;
        }

        .user-phone {
            position: absolute;
            font-size: 14px;
            color: #666666;
            margin-top: 32px;
            margin-left: 43px;
        }

        .user-card {
            position: absolute;
            font-size: 14px;
            color: #808080;
            margin-top: 11px;
            margin-left: 111px;
        }
    </style>
</head>
<body>

<div class="views tabs toolbar-through">
    <!--导航条-->
    <!-- Second view (for second wrap)-->
    <div id="view" class="view view-main tab active">
        <!-- We can make with view with navigation, let's add Top Navbar-->
        <div class="navbar">
            <div class="navbar-inner" style="background-color: #38a16d">
                <div class="left" id="back">
                    <a href="#" class="back link">
                        <i class="icon icon-back color-white" style="color: white"></i>
                        <span style="color: white">返回</span>
                    </a>
                </div>
                <div class="center sliding" style="color: white">就诊患者</div>
                <div class="right" id="addpeople">
                    <span style="color: white">添加</span>
                </div>
            </div>
        </div>

        <div class="pages navbar-through">
            <div data-page="index-2" class="page page-on-center">
                <div class="page-content">
                    <div id="contentPage">
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript" src="../js/framework7.min.js"></script>
<script type="text/javascript" src="../js/my-app.js"></script>
<script src="../js/jquery-1.10.2.js"></script>
<script src="../js/jquery.cookie.js"></script>
<script src="../js/ekang.js"></script>
<script>
    var paramObj;

    $(function() {
        var app = {
            //添加银行卡号
            getPeople: function () {
                $.ajax({
                    type: 'GET',
                    url: textUrl + 'user/familyList2',
                    data: {         // 需要于客户端同步
                        uid:$.cookie("local_userId"),
                        page_size:'500',
                        page_index:'1'
                    },
                    dataType: 'jsonp',
                    jsonp: 'callback',
                    success: function (result) {
                        if (result.ret == 0) {
                            var peopleList = result.data;

                            var items = '';
                            $.each(peopleList, function (i, o) {

                                paramObj = new Object();
                                paramObj.name = o.user_name;
                                paramObj.peopleId = o.id;
                                paramObj.mobile = o.mobile;
                                paramObj.card = o.identity_card;
                                paramObj.sex = o.sex;

                                items += '<div onclick="choosePeople(this)" data-id="'+ o.id+'" data-name="'+ o.user_name+'" style="position:relative;width: 100%;height: 60px;background-color: white;border-bottom: 1px solid #e6e6e6">';
                                if(o.is_default == 1){
                                    items += '<img src="../img/list-confirm.png" style="position:absolute ;width: 21px;height: 21px;left: 10px;margin-top: 19px"/>';
                                }else{
                                    items += '<img src="../img/list-cancel.png" style="position: absolute;width: 21px;height: 21px;left: 10px;margin-top: 19px"/>';
                                }
                                items += '<div class="user-name message">'+o.user_name+'</div>';
                                items += '<div class="message user-phone">'+o.mobile+'</div>';
                                items += '<div class="message user-card">'+o.identity_card+'</div>';
                                items += '<img src="../img/list-edit.png" alt="编辑" id="editBtn" style="position: absolute;width: 22px;height: 22px;right: 13px;margin-top: 19px;z-index: 1000"/>';
                                items += '</div>';
                            });
                            $('#contentPage').html(items);

                        }else{
                            alert(result.msg);
                        }
                    }
                });
            }
        };

        app.getPeople();


        $('#back').on('click', function () {
            history.back();
        });

        $('#addpeople').click(function () {
            location.href = "addPeople.html";
        });
    });

    function choosePeople (o) {
        if(getQueryString("type") == 1000){
            location.href = "edit_people.html?" + $.param(paramObj) + "";
        }else{
            var id=o.getAttribute("data-id");
            var name=o.getAttribute("data-name");

            $.ajax({
                type: 'GET',
                url: textUrl + '/user/setDefaultFamily/',
                data: {         // 需要于客户端同步
                    uid:$.cookie("local_userId"),
                    family_id:id
                },
                dataType: 'jsonp',
                jsonp: 'callback',
                success: function (result) {
                    if (result.ret == 0) {

                    } else {
                        alert(result.msg);
                    }
                }
            });

            $.cookie('username', name, { expires: 7,path: '/' });
            $.cookie('userId', id, { expires: 7,path: '/' });

            history.back();
        }


    }

</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
<script src="../js/weixin2.js"></script>
</body>
</html>